<html>
<body onload="startTest()">

<script src="../../resources/js-test.js"></script>
<script>

description("This test checks that moving an element with an event handler from one window (FrameHost) to another properly migrates the handler too.");

var jsTestIsAsync = true;
var window2;

function window2Loaded() {
    shouldBe('internals.scrollEventHandlerCount(document)', '0');
    var div = window2.document.getElementById("div");
    window.document.adoptNode(div);
    window.document.body.appendChild(div);
    shouldBe('internals.scrollEventHandlerCount(document)', '1');

    window2.close();
    finishJSTest();
}

function startTest() {
    if (window.testRunner) {
        testRunner.waitUntilDone();
        testRunner.setPopupBlockingEnabled(false);
    }
    window2 = window.open('resources/move-event-handler-between-framehosts-popup.html');
    window2.addEventListener("load", window2Loaded, false);
}

</script>

</body>
</html>
